#include "widget.h"
#include "ui_widget.h"
#include <QTabWidget>
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    QLabel* mylabel = new QLabel("test");

}

Widget::~Widget()
{
    delete ui;
}

//可以有两种添加逻辑：统一在最后；统一在选中页之前；也可以直接对这种逻辑都分别弄个按钮
void Widget::on_addPushButton_clicked()
{
    int cnt = ui->tabWidget->count();

    ui->tabWidget->addTab(new QWidget(this), "new tab" + QString::number(cnt));
    ui->tabWidget->setCurrentIndex(cnt);    //选中新建的标签页
}

void Widget::on_delPushButton_clicked()
{
    int index = ui->tabWidget->currentIndex();
    ui->tabWidget->removeTab(index);
}
